<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<%
	String path = request.getContextPath();
	// 获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量 
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	// 将 "项目路径basePath" 放入pageContext中，待以后用EL表达式读出。 
	pageContext.setAttribute("basePath", basePath);
	//out.write(basePath);
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生选课后显示页面</title>
<meta name="description"
	content="Source code generated using layoutit.com">
<meta name="author" content="LayoutIt!">

<link href="<%=basePath%>bootstrap/css/bootstrap.min.css"
	rel="stylesheet">
<link href="<%=basePath%>bootstrap/css/style.css" rel="stylesheet">

<script src="<%=basePath%>bootstrap/js/jquery.min.js"></script>
<script src="<%=basePath%>bootstrap/js/bootstrap.min.js"></script>
<script src="<%=basePath%>bootstrap/js/scripts.js"></script>

<script type="text/javascript">
	function getScores() {
		//获取成绩批量插入的参数格式，“主键id：成绩，主键id：成绩”
		var strParas = "";
		var i = 0;
		//成绩单主键
		var stuscoreid = $("#stuscoreid" + i).get(0);
		//成绩
		var stuscore = $("#stuscore" + i).get(0);
		while (stuscoreid != undefined && stuscoreid != null
				&& stuscore != undefined && stuscore != null) {
			//拼写字符串参数
			strParas += stuscoreid.value + ":" + stuscore.value + ",";
			//下标加1
			++i;
			//继续遍历
			stuscoreid = $("#stuscoreid" + i).get(0);
			stuscore = $("#stuscore" + i).get(0);
		}
		$("#txtscores")[0].value = strParas;

		console.info("txtscores:" + strParas);
	}

	function selected() {
		alert("添加成绩成功！")
	}
</script>

</head>

<body>
	<div>
		<form class="form-horizontal" role="form"
			action="<%=basePath%>CommitStuScore" method="post">
			<input type="hidden" class="form-control" id="txtscores"
				name='txtscores'>
			<h5 align="center">查看我的学生/成绩管理</h5>
			<table class="table table-bordered table-hover"
				style="text-align: center;">
				<tbody>
					<tr class="success">
						<td>#</td>
						<td>学生名</td>
						<td>课程名</td>
						<td>教师姓名</td>
						<td>分数</td>
						<td>输入成绩</td>
					</tr>
					<c:forEach items="${sessionScope.stuBean1}" var="eachuser"
						varStatus="statu">
						<tr>
							<input type="hidden" class="form-control"
								id="stuscoreid${statu.index}" name="stuscoreid${statu.index}"
								value="${eachuser.scoreid}">
							<td>${statu.index+1}</td>
							<td>${eachuser.stuname}</td>
							<td>${eachuser.classname}</td>
							<td>${eachuser.teaname}</td>
							<td>${eachuser.score}</td>
							<td><input type="text" id="stuscore${statu.index}"
								name='stuscore${statu.index}' style="text-align: center;"></td>

						</tr>
					</c:forEach>
				</tbody>
			</table>

			<div align="center">
				<div class="form-group">
					<div class="col-sm-offset-4 col-sm-1" align="right">
						<button type="submit" class="btn btn-default"
							onclick="getScores();selected();">全部提交</button>
					</div>
					<div class="col-sm-offset-1 col-sm-6" align="left">
						<button type="reset" class="btn btn-default">重置</button>
					</div>
				</div>
			</div>
		</form>
	</div>
</body>
</html>